Adds support for the keyword 'all' to the vcpu-pin operation.
authorEmmanuel Ackaouy <ack@xensource.com>
Tue, 26 Sep 2006 11:17:51 +0000 (12:17 +0100)
committerEmmanuel Ackaouy <ack@xensource.com>
Tue, 26 Sep 2006 11:17:51 +0000 (12:17 +0100)
Using 'all' in place of a specific vcpu will apply the cpumask
to all vcpus in the domain.
Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
docs/man/xm.pod.1
tools/python/xen/xend/XendDomain.py
tools/python/xen/xend/server/SrvDomain.py
tools/python/xen/xm/main.py

index 352eefd158910101ae645c56a3db293ac2e0efe9..e7dbbb90f6b585df25ba2d220a54af223490d62d 100644 (file)
@@ -393,7 +393,9 @@ specified, VCPU information for all domains will be provided.
 
 =item B<vcpu-pin> I<domain-id> I<vcpu> I<cpus>
 
-Pins the the VCPU to only run on the specific CPUs.  
+Pins the the VCPU to only run on the specific CPUs.  The keyword
+I<all> can be used to apply the I<cpus> list to all VCPUs in the
+domain.
 
 Normally VCPUs can float between available CPUs whenever Xen deems a
 different run state is appropriate.  Pinning can be used to restrict
index b434cb11867c46d975b1867a329672e098a1dad4..0642b3a8cd2eebd3d40f64b4cee00f70f43b0d48 100644 (file)
@@ -487,10 +487,19 @@ class XendDomain:
         if not dominfo:
             raise XendInvalidDomain(str(domid))
 
-        try:
-            return xc.vcpu_setaffinity(dominfo.getDomid(), vcpu, cpumap)
-        except Exception, ex:
-            raise XendError(str(ex))
+        # if vcpu is keyword 'all', apply the cpumap to all vcpus
+        vcpus = [ vcpu ]
+        if str(vcpu).lower() == "all":
+            vcpus = range(0, int(dominfo.getVCpuCount()))
+       
+        # set the same cpumask for all vcpus
+        rc = 0
+        for v in vcpus:
+            try:
+                rc = xc.vcpu_setaffinity(dominfo.getDomid(), int(v), cpumap)
+            except Exception, ex:
+                raise XendError(str(ex))
+        return rc
 
     def domain_cpu_sedf_set(self, domid, period, slice_, latency, extratime,
                             weight):
index d369aa68ad5e91e8721c7f586cb8b9ea02344ba5..52075340fddc37a906886a48deed89edf7ccd718 100644 (file)
@@ -97,7 +97,7 @@ class SrvDomain(SrvDir):
     def op_pincpu(self, _, req):
         fn = FormFn(self.xd.domain_pincpu,
                     [['dom', 'int'],
-                     ['vcpu', 'int'],
+                     ['vcpu', 'str'],
                      ['cpumap', 'str']])
         val = fn(req.args, {'dom': self.dom.domid})
         return val
index 3e1235091a140a923b0fe516659ec62d63b05ecb..c3dba40f8ef8a99c90e1cce01e8528ee37cc514f 100644 (file)
@@ -759,12 +759,16 @@ def xm_vcpu_pin(args):
                 for i in range(int(x),int(y)+1):
                     cpus.append(int(i))
             else:
-                cpus.append(int(c))
+                # remove this element from the list
+                if c[0] == '^':
+                    cpus = [x for x in cpus if x != int(c[1:])]
+                else:
+                    cpus.append(int(c))
         cpus.sort()
         return cpus
 
     dom  = args[0]
-    vcpu = int(args[1])
+    vcpu = args[1]
     cpumap = cpu_make_map(args[2])
     
     server.xend.domain.pincpu(dom, vcpu, cpumap)